package cn.edu.scau.cmi.yanghaorui.client;

import cn.edu.scau.cmi.yanghaorui.singleton.Marshal;
import cn.edu.scau.cmi.yanghaorui.singleton.President;
import javafx.application.Application;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.scene.control.Label;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextField;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.GridPane;
import javafx.stage.Stage;
import javafx.event.ActionEvent;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.control.Button;


public class MultipletonClient extends Application {

	@Override
	public void start(Stage primaryStage)throws Exception{
		GridPane gridPane = new GridPane();
		BorderPane borderPane = new BorderPane();
		Button button = new Button("创建元帅");
		TextField inputTextField = new TextField();
		inputTextField.setMaxSize(75,300);
		TextArea outputTextArea = new TextArea();
		outputTextArea.setMaxSize(500, 200);
		outputTextArea.setWrapText(true);
		borderPane.setCenter(outputTextArea);

		gridPane.setAlignment(Pos.CENTER);
		gridPane.setPadding(new Insets(10.5, 11.5, 12.5, 13.5));
		gridPane.setHgap(4.4);
		gridPane.setVgap(4.4);

		gridPane.add(new Label("元帅名字："), 0, 0);
		
		gridPane.add(inputTextField, 1, 0);
		gridPane.add(new Label("现有元帅："), 0, 2);
		gridPane.add(borderPane, 1, 2);
		gridPane.add(button, 2, 4);
		button.setOnAction(new EventHandler<ActionEvent>() {

			@Override
			public void handle(ActionEvent event) {
				// TODO Auto-generated method stub
				Marshal marshal = Marshal.getInstance(inputTextField.getText());
				outputTextArea.appendText(marshal.toString() + "\n");
			}
		});
		Scene scene = new Scene(gridPane, 750, 350);
		primaryStage.setTitle("SingletonClient");
		primaryStage.setScene(scene);
		primaryStage.show();





	}
	public static void main(String[] args) {
		// TODO Auto-generated method stub
		 Application.launch(args);

	}


}
